package agentes;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 *@author Joás
 * 
 */
public class Leitura {
	private StringBuffer stringBuffer = null;	
	/**
	 * @return the stringBuffer
	 */
	public StringBuffer getStringBuffer() {
		return stringBuffer;
	}	
	/**
	 * @param to path
	 * Construtor da classe
	 */
	public Leitura(String pathName){
		this.lendo(new File(pathName));
	}
	/**
	 * @param arquivo
	 * @return StringBuffer
	 */
	private StringBuffer lendo(File arquivo) {
		stringBuffer = new StringBuffer();
		int conteudo;
		try {
			FileReader reader = new FileReader(arquivo);
			do {
				conteudo = reader.read();
				if (conteudo != -1) {
					stringBuffer.append((char) conteudo);					
				}				
			} while (conteudo != -1);

			reader.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		return stringBuffer;
	
	}
	public void imprimeConteudoArquivo(){
		System.out.println(stringBuffer);
	}		
}
	
